package com.example.mobile2032021606170hsy0427;

import android.os.strictmode.WebViewMethodCalledOnWrongThreadViolation;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.PluralsRes;
import androidx.recyclerview.widget.RecyclerView;

import java.util.List;

public class CarageRVAdapter extends RecyclerView.Adapter<CarageRVAdapter.ViewHolder> {

    private List<Carage> list;

    public CarageRVAdapter(List<Carage> list) {
        this.list = list;
    }

    static class ViewHolder extends RecyclerView.ViewHolder {

        ImageView ivCarage;
        TextView tvName, tvVacancy, tvPrice, tvDistance, tvSite, tvMore;

        public ViewHolder(@NonNull View itemView) {
            super(itemView);
            ivCarage = itemView.findViewById(R.id.iv_item_car);
            tvName = itemView.findViewById(R.id.tv_item_car);
            tvVacancy = itemView.findViewById(R.id.tv_item_car1);
            tvPrice = itemView.findViewById(R.id.tv_item_car2);
            tvDistance = itemView.findViewById(R.id.tv_item_car3);
            tvSite = itemView.findViewById(R.id.tv_item_car4);
            tvMore = itemView.findViewById(R.id.tv_item_car5);
        }
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext())
                .inflate(R.layout.item_rv_main_carage, parent, false);
        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
        Carage carage = list.get(position);
        holder.ivCarage.setImageResource(carage.getCarageIds());
        holder.tvName.setText(carage.getName());
        holder.tvVacancy.setText(carage.getVacancy());
        holder.tvPrice.setText(carage.getPrice());
        holder.tvDistance.setText(carage.getDistance());
        holder.tvSite.setText(carage.getSite());
        holder.tvMore.setText(carage.getMore());


    }

    @Override
    public int getItemCount() {
        return list.size();
    }


}
